home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 44 / Amiga Format CD44 (1999-08-26)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-10].iso / +system+ / afcd_install next >
Text File  |  1999-07-30  |  12KB  |  478 lines

  1. ; $VER: AFCD_Install 1.0 (17.6.99)
  2. ;   by Oliver Roberts (oliver.roberts@iname.com)
  3.  
  4. ;*************
  5. ; LOCALE INIT
  6. ;*************
  7.  
  8. (if (= (exists "Env:Language") 1)
  9.     (set @language (getenv "Language"))
  10. )
  11.  
  12. ;*****************
  13. ; ENGLISH STRINGS
  14. ;*****************
  15.  
  16. (set #str-yes "Yes")
  17. (set #str-no "No")
  18. (set #str-askfind "Copy AFCDFind to your hard drive?")
  19. (set #str-findno "No - I'd rather use it from the CD")
  20. (set #str-findprog "Yes - Just the program itself")
  21. (set #str-findall "Yes - The program and all the indices")
  22. (set #str-finddest "Select where the AFCDFind program files should be installed (no drawer will be created!)")
  23. (set #str-askaminet "Copy the Aminet index listing to your hard drive?\n(requires approx 5Mb disk space)")
  24. (set #str-copyaminetindex "Copying Aminet index file")
  25. (set #str-settooltypes "Setting tooltypes")
  26. (set #str-updating "Updating %s")
  27. (set #str-updateinstaller "Checking to see whether Installer should be updated")
  28. (set #str-updateview "Checking to see whether AFCDView needs to be copied to C: (i.e. if it's not there already or you have an old version")
  29. (set #str-notoncd "Set the NOTONCD tooltype?\n(see help for info)")
  30. (set #str-indexdir "Select where the AFCD index files should be installed")
  31. (set #str-dopus (cat
  32.     "If you wish to use the features in AFCDFind that utilise Directory "
  33.     "Opus, you will need to install the support script for these "
  34.     "features to work.  Install the script?"
  35. ))
  36. (set #str-dopusdest "Select where the script should be installed")
  37. (set #str-aminetdest "Select where the Aminet index file should be installed")
  38. (set #str-complete (cat
  39.     "Installation of your chosen files has now been completed\n\n"
  40.     "The choices that you have made will be saved and will be used "
  41.     "as the defaults when you next run this installer"
  42. ))
  43. (set #str-installmode (cat
  44.     "Do you wish to view/change your existing settings or just update "
  45.     "the files using your current settings?"
  46. ))
  47. (set #str-modenew "Change these settings")
  48. (set #str-modeview "View settings")
  49. (set #str-modeupdate "Update files")
  50.  
  51. (set #help-updateinstaller (cat
  52.     "This installer script will automatically update your copy of Installer "
  53.     "if you are using an older version"
  54. ))
  55. (set #help-updateview (cat
  56.     "This installer script will automatically update your copy of AFCDView "
  57.     "which is required to view files on this CD via the AFCDPrefs system"
  58. ))
  59. (set #help-find (cat
  60.     "Although AFCDFind works just fine from the CD, you may wish to "
  61.     "install it on your hard drive.  If so, then there are two different "
  62.     "variations to choose from:\n\n"
  63.     "1. Just the AFCDFind program files will be copied to your hard "
  64.     "drive.  You could then create a \"left out\" icon via Workbench "
  65.     "so you can easily access AFCDFind from Workbench.  However, for "
  66.     "this to work, you'll still need an AFCD in your drive.\n\n"
  67.     "2. In addition to copying all the AFCDFind program files to your "
  68.     "hard drive, you can choose to copy all the CD index files too.  "
  69.     "This may be faster, and it also means that you can use AFCDFind "
  70.     "even if there is no AFCD in your CD drive.  However, you'll need "
  71.     "to have quite a bit of spare space to use this option (30Mb+ at "
  72.     "the time of writing!\n\n"
  73. ))
  74. (set #help-notoncd (cat
  75.     "Currently, setting this tooltype just changes the text in the Search "
  76.     "cycle gadget.  Normally, there will be \"This CD\" and \"Last 5 CDs\" options. "
  77.     "If you specify this tooltype, these will be replaced with the actual CD "
  78.     "numbers. You may prefer this when running AFCDFind off your hard drive "
  79.     "instead of the CD.\n\n"
  80. ))
  81.  
  82. ;************
  83. ; PROCEDURES
  84. ;************
  85.  
  86. (procedure P_SaveChoices
  87.     (textfile
  88.         (dest "ENV:AFCD_Install")
  89.         (append
  90.             (cat
  91.                 ("FINDINSTALL=%ld\n" #findinstall)
  92.                 ("FINDDIR=%s\n" #finddir)
  93.                 ("AMINETINSTALL=%ld\n" #aminetinstall)
  94.                 ("AMINETDIR=%s\n" #aminetdir)
  95.                 ("FINDDOPUS=%ld\n" #find-dopus)
  96.             )
  97.         )
  98.         (safe)
  99.     )
  100.     (copyfiles
  101.         (source "ENV:AFCD_Install")
  102.         (dest "ENVARC:")
  103.         (nogauge)
  104.         (safe)
  105.     )
  106. )
  107.  
  108. (procedure P_ReadFindTooltypes
  109.     (set #indexdir (tackon #finddir "AFCD_Indices"))
  110.     (set #matchscript (tackon #finddir "AFCDFind-HandleMatch.dopus5"))
  111.     (if (AND (exists (tackon #finddir "AFCDFind.info")) (>= @installer-version 2752524))
  112.         (
  113.             (set #find-notoncd "off")
  114.             (iconinfo
  115.                 (dest (tackon #finddir "AFCDFind"))
  116.                 (gettooltype "NOTONCD" "#find-notoncd")
  117.                 (gettooltype "INDEXDIR" "#indexdir")
  118.                 (gettooltype "MATCHSCRIPT" "#matchscript")
  119.                 (safe)
  120.             )
  121.         )
  122.     )
  123.     (set #find-notoncd (<> "off" #find-notoncd))
  124.     (if (= #indexdir (cat #cddevice ":+System+/Indices"))
  125.         (set #indexdir (tackon #finddir "AFCD_Indices"))
  126.     )
  127. )
  128.  
  129. (procedure P_GetViewSettingsString
  130.     (cat
  131.         ("Install AFCDFind?   %s\n" (select #findinstall #str-findno #str-findprog #str-findall))
  132.         ("Destination:   %s\n" #finddir)
  133.         ("Index dir:   %s\n" #indexdir)
  134.         ("NOTONCD tooltype:   %s\n" (if #find-notoncd "Set" "Unset"))
  135.         ("DOpus support:   %s\n\n" (if #find-dopus #matchscript "Off"))
  136.         ("Install Aminet Index?  %s\n" (if #aminetinstall #str-yes #str-no))
  137.         ("Destination:   %s" #aminetdir)
  138.     )
  139. )
  140.  
  141. ;******
  142. ; INIT
  143. ;******
  144.  
  145. (if (= "AFCD" (substr (expandpath ":") 0 4))
  146.     ; started from an AFCD
  147.     (set #cddevice (getdevice ":"))
  148.     ; not started from an AFCD (for testing purposes)
  149.     (set #cddevice "CD0")
  150. )
  151.  
  152. (set #finddir @default-dest)
  153. (set #aminetdir @default-dest)
  154. (set #findinstall 0)
  155. (set #aminetinstall 0)
  156. (set #find-notoncd 1)
  157. (set #find-dopus 1)
  158.  
  159. (set #config (getenv "AFCD_Install"))
  160. (set #configsize (strlen #config))
  161.  
  162. (if (> #configsize 0)
  163.     (
  164.         (set #i 0)
  165.  
  166.         (until (>= #i #configsize)
  167.             (
  168.                 (set #k #i)
  169.                 (while (<> (substr #config #i 1) "=")
  170.                     (set #i (+ #i 1))
  171.                 )
  172.                 (set #var (substr #config #k (- #i #k)))
  173.                 (set #i (+ #i 1))
  174.                 (set #k #i)
  175.                 (while (<> (substr #config #i 1) "\n")
  176.                     (set #i (+ #i 1))
  177.                 )
  178.                 (if (> (- #i #k) 0)
  179.                     (
  180.                         (set #val (substr #config #k (- #i #k)))
  181.                         (if (= "FINDINSTALL" #var)
  182.                             (set #findinstall (+ #val))
  183.                         )
  184.                         (if (= "FINDDIR" #var)
  185.                             (set #finddir #val)
  186.                         )
  187.                         (if (= "AMINETINSTALL" #var)
  188.                             (set #aminetinstall (+ #val))
  189.                         )
  190.                         (if (= "AMINETDIR" #var)
  191.                             (set #aminetdir #val)
  192.                         )
  193.                         (if (= "FINDDOPUS" #var)
  194.                             (set #find-dopus (+ #val))
  195.                         )
  196.                     )
  197.                 )
  198.                 (set #i (+ #i 1))
  199.             )
  200.         )
  201.     )
  202.                 
  203. )
  204.  
  205. ;*******************
  206. ; INTERACTIVE START
  207. ;*******************
  208.  
  209. (welcome)
  210.  
  211. (if (> #configsize 0)
  212.     (
  213.         (P_ReadFindTooltypes)
  214.         (set #interactive 1)
  215.         (set #interactive
  216.             (askchoice
  217.                 (prompt (P_GetViewSettingsString))
  218.                 (help @askchoice-help)
  219.                 (choices (cat (if (< @installer-version 2752518) "" "\x1b[2p") #str-modenew) #str-modeupdate)
  220.                 (default #interactive)
  221.             )
  222.         )
  223.     )
  224.     ; else
  225.     (set #interactive 0)
  226. )
  227.  
  228. (if (= #interactive 0)
  229.     (
  230.         (set #findinstall
  231.             (askchoice
  232.                 (prompt #str-askfind)
  233.                 (help #help-find @askchoice-help)
  234.                 (choices (cat (if (< @installer-version 2752518) "" "\x1b[2p") #str-findno) #str-findprog #str-findall)
  235.                 (default #findinstall)
  236.             )
  237.         )
  238.  
  239.         (if #findinstall
  240.             (
  241.                 (set #finddir
  242.                     (askdir
  243.                         (prompt #str-finddest)
  244.                         (help @askdir-help)
  245.                         (default #finddir)
  246.                     )
  247.                 )
  248.                 (P_ReadFindTooltypes)
  249.                 (if (= #findinstall 2)
  250.                     (set #indexdir
  251.                         (askdir
  252.                             (prompt #str-indexdir)
  253.                             (help @askdir-help)
  254.                             (default #indexdir)
  255.                             (newpath)
  256.                         )
  257.                     )
  258.                 )
  259.                 (set #find-notoncd
  260.                     (askchoice
  261.                         (prompt #str-notoncd)
  262.                         (help #help-notoncd @askchoice-help)
  263.                         (choices (cat (if (< @installer-version 2752518) "" "\x1b[2p") #str-no) #str-yes)
  264.                         (default #find-notoncd)
  265.                     )
  266.                 )
  267.                 (set #find-dopus
  268.                     (askchoice
  269.                         (prompt #str-dopus)
  270.                         (help @askchoice-help)
  271.                         (choices (cat (if (< @installer-version 2752518) "" "\x1b[2p") #str-no) #str-yes)
  272.                         (default #find-dopus)
  273.                     )
  274.                 )
  275.                 (if #find-dopus
  276.                     (set #matchscript (tackon
  277.                         (askdir
  278.                             (prompt #str-dopusdest)
  279.                             (help @askdir-help)
  280.                             (default #matchscript)
  281.                         )
  282.                         "AFCDFind-HandleMatch.dopus5")
  283.                     )
  284.                 )
  285.             )
  286.         )
  287.  
  288.         (set #aminetinstall
  289.             (askchoice
  290.                 (prompt #str-askaminet)
  291.                 (help @askchoice-help)
  292.                 (choices (cat (if (< @installer-version 2752518) "" "\x1b[2p") #str-no) #str-yes)
  293.                 (default #aminetinstall)
  294.             )
  295.         )
  296.  
  297.         (if #aminetinstall
  298.             (set #aminetdir
  299.                 (askdir
  300.                     (prompt #str-aminetdest)
  301.                     (help @askdir-help)
  302.                     (default #aminetdir)
  303.                 )
  304.             )
  305.         )
  306.     )
  307.     ; else
  308.     (
  309.         (P_ReadFindTooltypes)
  310.     )
  311. )
  312.  
  313. ;*******************
  314. ; COPY FILES ACROSS
  315. ;*******************
  316.  
  317. (onerror (P_SaveChoices))
  318.  
  319. (complete 0)
  320.  
  321. (working #str-updateinstaller)
  322.  
  323. (if (= 0 (run "C:Which Installer NORES >ENV:AFCDInst_tmp" (safe)))
  324.     (
  325.         (set #installerloc (getenv "AFCDInst_tmp"))
  326.         (set #installerloc (substr #installerloc 0 (- (strlen #installerloc) 1)))
  327.     )
  328.     ;else
  329.     (set #installerloc "C:")
  330. )
  331. (delete "ENV:AFCDInst_tmp" (safe))
  332.  
  333. (copylib
  334.     (prompt (#str-updating #installerloc))
  335.     (help #help-updateinstaller)
  336.     (source (cat #cddevice ":C/Installer"))
  337.     (dest (pathonly #installerloc))
  338.     (confirm)
  339. )
  340.  
  341. (complete 8)
  342.  
  343. (working #str-updateview)
  344.  
  345. (copylib
  346.     (prompt (#str-updating "C:AFCDView"))
  347.     (help #help-updateview)
  348.     (source (cat #cddevice ":C/AFCDView"))
  349.     (dest "C:")
  350.     (confirm)
  351. )
  352.  
  353. (complete 10)
  354.  
  355. (if #findinstall
  356.     (
  357.         (copylib
  358.             (source (cat #cddevice ":+System+/Find"))
  359.             (dest #finddir)
  360.             (newname "AFCDFind")
  361.         )
  362.         (if (NOT (exists (tackon #finddir "AFCDFind.info")))
  363.             (
  364.                 (copyfiles
  365.                     (source (cat #cddevice ":+System+/Find.info"))
  366.                     (dest #finddir)
  367.                     (newname "AFCDFind.info")
  368.                 )
  369.                 (tooltype
  370.                     (prompt #str-settooltypes)
  371.                     (dest (tackon #finddir "AFCDFind"))
  372.                     (noposition)
  373.                 )
  374.             )
  375.         )
  376.         ; clear tooltypes first (bug in installer)
  377.         (tooltype
  378.             (prompt #str-settooltypes)
  379.             (dest (tackon #finddir "AFCDFind"))
  380.             (settooltype "NOTONCD")
  381.             (settooltype "(NOTONCD)")
  382.             (settooltype "FASTSTARTUP")
  383.             (settooltype "(FASTSTARTUP)")
  384.             (settooltype "HELPFILE")
  385.             (settooltype "(HELPFILE")
  386.             (settooltype "MATCHSCRIPT")
  387.             (settooltype "(MATCHSCRIPT")
  388.             (settooltype "INDEXDIR")
  389.             (settooltype "(INDEXDIR")
  390.         )
  391.         ; now set tooltypes
  392.         (tooltype
  393.             (prompt #str-settooltypes)
  394.             (dest (tackon #finddir "AFCDFind"))
  395.             (if (= 1 #find-notoncd) (settooltype "NOTONCD" "") (settooltype "(NOTONCD)" ""))
  396.             (settooltype (if (= 2 #findinstall) "(FASTSTARTUP)" "FASTSTARTUP") "")
  397.             (settooltype "HELPFILE" (tackon #finddir "AFCDFind.guide"))
  398.             (settooltype "MATCHSCRIPT" #matchscript)
  399.             (settooltype "INDEXDIR" (if (= #findinstall 2) #indexdir (cat #cddevice ":+System+/Indices")))
  400.         )
  401.         (if (exists (cat #cddevice ":+System+/Info/AFCDFind.guide"))
  402.             (copyfiles
  403.                 (source (cat #cddevice ":+System+/Info/AFCDFind.guide"))
  404.                 (dest #finddir)
  405.                 (infos)
  406.             )
  407.         )
  408.         (if #find-dopus
  409.             (copyfiles
  410.                 (source (cat #cddevice ":S/AFCDFind-HandleMatch.dopus5"))
  411.                 (dest #finddir)
  412.                 (infos)
  413.             )
  414.         )
  415.     )
  416. )
  417.  
  418. (complete 30)
  419.  
  420. (if (= #findinstall 2)
  421.     (
  422.         (if (NOT (exists #indexdir))
  423.             (makedir #indexdir (infos))
  424.         )
  425.         (foreach (cat #cddevice ":+System+/Indices") "(AFCD?|AFCD??)"
  426.             (if (< @each-type 0)
  427.                 (
  428.                     (set #docopyidx 1)
  429.                     (set #idxname (cat #cddevice ":+System+/Indices/" @each-name))
  430.                     (if (exists (tackon #indexdir @each-name))
  431.                         (if (NOT (earlier (tackon #indexdir @each-name) #idxname))
  432.                             (set #docopyidx 0)
  433.                         )
  434.                     )
  435.                     (if #docopyidx
  436.                         (copyfiles
  437.                             (source #idxname)
  438.                             (dest #indexdir)
  439.                             (infos)
  440.                         )
  441.                     )
  442.                 )
  443.             )
  444.         )
  445.     )
  446. )
  447.  
  448. (complete 90)
  449.  
  450. (if #aminetinstall
  451.     (copyfiles
  452.         (prompt #str-copyaminetindex)
  453.         (help @copyfiles-help)
  454.         (source (cat #cddevice ":-In_the_Mag-/Reader_Requests/Aminet_Index"))
  455.         (dest #aminetdir)
  456.         (infos)
  457.         (noposition)
  458.         (optional nofail askuser)
  459.         (confirm)
  460.     )
  461. )
  462.  
  463. ;**************
  464. ; SAVE CHOICES
  465. ;**************
  466.  
  467. (complete 99)
  468.  
  469. (P_SaveChoices)
  470.  
  471. ;*********
  472. ; THE END
  473. ;*********
  474.  
  475. (complete 100)
  476.  
  477. (exit #str-complete (quiet))
  478.